<?php
// 应用公共文件
declare (strict_types=1);

use app\common\exception\BaseException;


/**
 * @notes 字符串参数过滤空格
 * @param $params
 * @return mixed|string
 * @author mjf
 * @date 2022/4/1 18:46
 */
function filter_trim($params)
{
    return is_string($params) ? trim($params) : $params;
}

/**
 * @notes 异常错误
 * @param string $message
 * @param int|null $status
 * @param array $data
 * @throws BaseException
 * @author mjf
 * @date 2022/4/13 17:22
 */
function throwError(string $message, ?int $status = null, array $data = [])
{
    is_null($status) && $status = config('status.error');
    throw new BaseException(['status' => $status, 'msg' => $message, 'data' => $data]);
}
